from flask_wtf import FlaskForm
from flask_wtf.file import FileRequired, FileAllowed
from wtforms import StringField, PasswordField, SubmitField, DateField, IntegerField, FileField
from wtforms.validators import DataRequired

# 登录表单
class LoginForm(FlaskForm):
    username = StringField(label = '用户名',default='admin')
    password = PasswordField(label='密码')
    submit = SubmitField('登录')


# 注册表单
class RegisterForm(FlaskForm):
    username = StringField(label='用户名', default='')
    password = PasswordField(label='密码',validators=[DataRequired('请输入密码')])
    birth_date = DateField(label='生日')
    age = IntegerField(label='年龄')
    submit = SubmitField('注册')



# 文件上传
class UserAvatarForm(FlaskForm):
    avatar = FileField(label='上传文件',validators=
        [FileRequired('请选择文件'),
        FileAllowed(['png','jpeg','xlsx','docx','rar','doc','xls','pdf','zip'],'不支持的文件格式')
     ])

